package sun.superstring.interface3;

public class ClassDataInterImpl1 implements ClassDateInter {
    private Student [] students; // 记住送来的全班学生信息。
    // 用有参构造器来接
    public ClassDataInterImpl1(Student[] students) {
        this.students = students;
    }

    @Override
    public void printAllStudentsInfos() {
        for(int i=0; i<students.length; i++){
            Student s = students[i];
            System.out.println(s.getName() + " " + s.getSex() + " " + s.getScore());
        }
    }

    @Override
    public void printAverageScore() {
        double sum = 0;
        for (int i = 0; i < students.length; i++) {
            Student s = students[i];
            sum += s.getScore();
        }
        System.out.println("全班同学平均成绩是：" + sum / students.length);

    }
}
